import { connect, pluralize } from 'mongoose'
import { MONGO, NODE_ENV } from '../config/constant'
import { logger } from '../log/log'
const connectMongo = async () => {
  await connect(MONGO[NODE_ENV].url, {
    autoIndex: false
  })
    .then(() => {
      pluralize(null)
      logger.info('数据库连接成功')
    })
    .catch((err) => {
      logger.error('数据库连接失败', err)
    })
}
export default connectMongo
